package com.xf.common;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

public class Serviceinfo implements Serializable {
    private String address;
    private Integer port;
    private HashMap<String,HashMap<String,Vector<String>>> selectinfo;

    public Serviceinfo(String address, Integer port, HashMap<String,HashMap<String,Vector<String>>> selectinfo) {
        this.address = address;
        this.port = port;
        this.selectinfo = selectinfo;
    }

    public String getAddress() {
        return address;
    }

    public Integer getPort() {
        return port;
    }
    public void print(){
        System.out.println("serviceinformation from: "+address+":"+port);
        for (String key : selectinfo.keySet()){
            System.out.println("servicename: "+key);
            System.out.println("methods:");
            HashMap<String, Vector<String>> stringVectorHashMap = selectinfo.get(key);
            for (String k:stringVectorHashMap.keySet()){
                System.out.print(k+"   from ");
                Vector<String> vector = stringVectorHashMap.get(k);
                System.out.print(vector.get(0));
                for(int i=1;i<vector.size();i++){
                    System.out.print("/"+vector.get(i));
                }
                System.out.println();
            }
        }
    }
//    public void print(){
//        System.out.println("serviceinformation from: "+address+":"+port);
//        for (String key : serviceinfo.keySet()) {
//            System.out.println("service from: "+key);
//            HashMap<String,Vector<Invocation>> inhashmap=serviceinfo.get(key);
//            for(String k :inhashmap.keySet()){
//                System.out.println("servicename: "+k);
//                Vector<Invocation> invocation=inhashmap.get(k);
//                System.out.println("methods: ");
//                for (Invocation element : invocation) {
//                    System.out.print(element.getMethodName());
//                    if(element.getParameterTypes().length==0){
//                        System.out.print("()");
//                    }
//                    else{
//                        System.out.print("(");
//                        System.out.print(element.getParameterTypes()[0].getSimpleName());
//                        for (int i = 1; i < element.getParameterTypes().length; i++) {
//                            System.out.print(","+element.getParameterTypes()[i].getSimpleName());
//                        }
//                        System.out.print(")");
//                    }
//                    System.out.print("\n");
//                }
//            }
//        }
//        System.out.println();
//    }
}
